package com.svs.web.controller.project;

import java.util.List;

import com.svs.common.utils.ExcelUtil;
import com.svs.framework.shiro.util.ShiroUtils;
import com.svs.project.domain.ProLineLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.svs.common.annotation.Log;
import com.svs.common.enums.BusinessType;
import com.svs.project.domain.ProMonitor;
import com.svs.project.service.ProMonitorService;
import com.svs.framework.web.BaseController;
import com.svs.framework.web.page.TableDataInfo;
import com.svs.common.base.AjaxResult;

/**
 * 显示器管理 信息操作处理
 * 
 * @author 杜建桥
 * @date 2023-08-12
 */
@Controller
@RequestMapping("/project/proMonitor")
public class ProMonitorController extends BaseController {

    private String prefix = "project/proMonitor";
	
	@Autowired
	private ProMonitorService proMonitorService;
	
	@RequiresPermissions("project:proMonitor:view")
	@GetMapping()
	public String proMonitor() {
	    return prefix + "/proMonitorList";
	}
	
	/**
	 * 查询显示器管理列表
	 */
	@RequiresPermissions("project:proMonitor:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ProMonitor proMonitor) {
		startPage();
        List<ProMonitor> list = proMonitorService.selectAllList(proMonitor);
		return getDataTable(list);
	}
	
	/**
	 * 新增显示器管理
	 */
	@GetMapping("/add")
	public String add() {
	    return prefix + "/addProMonitor";
	}
	
	/**
	 * 新增保存显示器管理
	 */
	@RequiresPermissions("project:proMonitor:add")
	@Log(title = "显示器管理", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ProMonitor proMonitor) {
		proMonitor.setCreateBy(ShiroUtils.getLoginName());
		return toAjax(proMonitorService.save(proMonitor));
	}

	/**
	 * 修改显示器管理
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap) {
		ProMonitor proMonitor = proMonitorService.selectByPrimaryKey(id);
		mmap.put("proMonitor", proMonitor);
	    return prefix + "/editProMonitor";
	}
	
	/**
	 * 修改保存显示器管理
	 */
	@RequiresPermissions("project:proMonitor:edit")
	@Log(title = "显示器管理", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ProMonitor proMonitor) {
		proMonitor.setUpdateBy(ShiroUtils.getLoginName());
		return toAjax(proMonitorService.update(proMonitor));
	}
	
	/**
	 * 删除显示器管理
	 */
	@RequiresPermissions("project:proMonitor:remove")
	@Log(title = "显示器管理", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String[] ids) {		
		return toAjax(proMonitorService.deleteByPrimaryKeys(ids));
	}

	@Log(title = "显示器管理", businessType = BusinessType.EXPORT)
	@RequiresPermissions("project:proMonitor:export")
	@PostMapping("/export")
	@ResponseBody
	public AjaxResult export(ProMonitor proMonitor) {
		List<ProMonitor> list = proMonitorService.selectAllList(proMonitor);
		ExcelUtil<ProMonitor> util = new ExcelUtil<>(ProMonitor.class);
		return util.exportExcel(list, "proMonitor");
	}
}
